﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProcessManagerXNA.Process;
using Microsoft.Xna.Framework.Audio;

namespace ProcessManagerXNA.Processes
{
    public class SoundProcess : BaseProcess
    {
        private readonly SoundEffectInstance soundInstance;

        public SoundProcess(SoundEffect sound)
        {
            soundInstance = sound.CreateInstance();
        }

        public override void  OnInit()
        {
 	        base.OnInit();
            soundInstance.Play();
        }

        public override void OnUpdate(Microsoft.Xna.Framework.GameTime gameTime)
        {
            if(soundInstance.IsDisposed || soundInstance.State == SoundState.Stopped)
                Succeed();
        }

        public override void OnSuccess()
        {
        }

        public override void OnFail()
        {
        }

        public override void OnAbort()
        {
        }
    }
}
